//检索
function searchs(){
    top.jzts();
    $("#form").submit();
}

//详情
function detail(id) {
    top.jzts();
    var diag = new top.Dialog();
    diag.Drag = true;
    diag.Title = "详情";
    diag.URL = path + '/admin/platformScaleConfig/detailPage?id='+ id;
    diag.Width = 1050;
    diag.Height = 580;
    diag.CancelEvent = function(){ //关闭事件
        diag.close();
    };
    diag.show();
}

//当所有收益类型全部已经存在对应收益分成配置时，点击新增按钮给出提示，
//当前所有收益类型均已存在对应收益分成配置，无法继续新增
function validateAdd() {
    var flag = false;
    $.ajax({
        url : path + "/admin/platformScaleConfig/validateAdd",
        type : "post",
        async : false,
        dataType : "json",
        success : function (data) {
            //如果当前所有收益类型均已存在对应收益分成配置那么code等于200，否则code等于400
            if (data.code == 200) {
                flag = true;
            }
        }
    });
    return flag;
}

//新增
function add(currentPage){
    var flag = validateAdd();
    if (flag) {
        bootbox.alert({
            message: '当前所有收益类型均已存在对应收益分成配置，无法继续新增！',
            buttons: {
                ok: {
                    label: '我知道了'
                }
            }
        });
        return false;
    }
    top.jzts();
    var diag = new top.Dialog();
    diag.Drag = true;
    diag.Title ="新增";
    diag.URL = path + '/admin/platformScaleConfig/addPage';
    diag.Width = 1050;
    diag.Height = 580;
    diag.CancelEvent = function(){//关闭事件
        if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
            if(currentPage == '0'){
                top.jzts();
                setTimeout("self.location=self.location",100);
            }else{
                nextPage(currentPage);
            }
        }
        diag.close();
    };
    diag.show();
}

//编辑
function edit(id, currentPage){
    top.jzts();
    var diag = new top.Dialog();
    diag.Drag = true;
    diag.Title ="编辑";
    diag.URL = path + '/admin/platformScaleConfig/editPage?id=' + id;
    diag.Width = 1050;
    diag.Height = 580;
    diag.CancelEvent = function(){//关闭事件
        if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
            if(currentPage == '0'){
                top.jzts();
                setTimeout("self.location=self.location",100);
            }else{
                nextPage(currentPage);
            }
        }
        diag.close();
    };
    diag.show();
}
